package com.shundr.shipper.common.util;

import java.util.ArrayList;
import java.util.List;

import com.shundr.shipper.common.dao.AttributeDao;
import com.shundr.shipper.common.model.AttributeInfo;

import android.annotation.SuppressLint;
import android.content.Context;

@SuppressLint("InflateParams")
public class AttrUtil{
	
	public static final String TYPE_TRUCK = "TruckType";//车辆类型
	public static final String TYPE_TRUCK_LENGTH = "TruckLength";//车辆长度
	public static final String TYPE_CARGO_WEIGHT = "CargoWeight";//货物重量
	public static final String TYPE_PROVINCE_SHORT = "ProvinceShort";//省份简称
	
	public static void init(Context context){
		if(new AttributeDao().isNeedInit()){
			List<AttributeInfo> list = new ArrayList<AttributeInfo>();
			for (int i = 0; i < TruckType.length; i++) {
				AttributeInfo truck = new AttributeInfo();
				truck.setCode(TruckTypecode[i]);
				truck.setName(TruckType[i]);
				truck.setType(TYPE_TRUCK);
				list.add(truck);
			}
			
			for (int j = 0; j < TruckLength.length; j++) {
				AttributeInfo length = new AttributeInfo();
				length.setCode(TruckLengthCode[j]);
				length.setName(TruckLength[j]);
				length.setType(TYPE_TRUCK_LENGTH);
				list.add(length);
			}
			
			for (int k = 0; k < CargoWeight.length; k++) {
				AttributeInfo weight = new AttributeInfo();
				weight.setCode(CargoWeightCode[k]);
				weight.setName(CargoWeight[k]);
				weight.setType(TYPE_CARGO_WEIGHT);
				list.add(weight);
			}
			
			for (int h = 0; h < ProsForShort.length; h++) {
				AttributeInfo ps = new AttributeInfo();
				ps.setCode(ProsForShort[h]);
				ps.setName(ProsForShort[h]);
				ps.setType(TYPE_PROVINCE_SHORT);
				list.add(ps);
			}
			
			new AttributeDao().syncData(list);
		}
	}
	
	/**
	 * 车辆类型
	 */ 

	public static String TruckType[] = { "不限", "高栏车", "半挂车", "零担车", "平板车", "栏板车","危险运输",
			"冷藏车", "厢式货车", "油罐车", "集装箱车", "面包车", "保温车","特种车","低板车",
			 "其他" };
	/**
	 * 车辆类型code
	 */
	public static String TruckTypecode[] = { "null", "1", "2", "3", "4", "5","6",
			"7", "8","10","13", "16", "17", "32","35","99" };
	/**
	 * 车辆长度
	 */ 
	public static String TruckLength[] = { "不限", "4.2米", "4.8米", "5.0米", "5.2米",
			"5.8米", "6.2米", "6.8米", "7.2米", "8.6米", "9.6米", "10米", "12.5米",
			"13米", "16米", "17.5米", "6米以下", "6-9米", "9-11米", "11-15米", "15-18米",
			"18-23米", "23米以上" };
	/**
	 * 车辆长度code
	 */ 
	public static String TruckLengthCode[] = { "null", "4.2", "4.8", "5.0", "5.2",
			"5.8", "6.2", "6.8", "7.2", "8.6", "9.6", "10", "12.5", "13", "16",
			"17.5", "0-6", "6-9", "9-11", "11-15", "15-18", "18-23", "23" };

	/**
	 * 车载重(货的重量)
	 */ 
	public static String CargoWeight[] = { "不限", "8吨以下", "8-10吨", "10-15吨",
			"15-20吨", "20-25吨", "25-30吨", "30吨以上" };
	/**
	 * 车载重(货的重量)code
	 */
	public static String CargoWeightCode[] = { "null", "0-8", "8-10", "10-15",
			"15-20", "20-25", "25-30", "30-0" };
	
	public static String ProsForShort[] = { "京", "津", "沪", "渝", "蒙", "新", "藏", "宁", "桂", "港",
			"澳", "黑", "吉", "辽", "晋", "冀", "青", "鲁", "豫", "苏", "皖", "浙", "闽", "赣", "湘", "鄂", "粤",
			"琼", "甘", "陕", "黔", "滇", "川" };
}
